<?php
// $Id$

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/vpage/tcms_vpage_dbc.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/vpt/vpage_abs_dbc.class.php');


class VPage_301_DBC extends VPage_Abs_DBC {
	private $location = '';

	function __construct() {

	}


	public function save(DB_Connection $dbc, $current_user_id = 0) {
		$ret = false;

		if ($this->get_id()) {
			$vpage = new TCMS_VPage_DBC();
			if ($vpage->load_by_id($dbc, $this->get_id())) {

				$this->save_system_attribute($dbc, $vpage->get_id(), $vpage->get_template(), 'location', $this->get_location());

				TCMS_VPage_DBC::update_last_modified($dbc, $vpage->get_id(), $current_user_id);

				$ret = true;
			}
		}

		return $ret;
	}


	public function load_by_id(DB_Connection $dbc, $id) {
		tangra_if_not_int_throw_e($id);

		$location = $this->load_system_attribute($dbc, $id, 'location');
		if ($location) {
			$this->set_location($location->get_value());
		}

		$this->set_vpage_id($id);

		return $id;
	}


	public function set_location($location) {
		$this->location = $location;
	}


	public function get_location() {
		return $this->location;
	}
}